package logic.nodes.nodeSettings;

import fileHandling.language.Lang;

import interfaces.options.OptionWidget;
import interfaces.options.OptionsContainer;

public class Settings extends AbstractSettings<SettingsOption> {
	
	public Settings() {
		super();
	}
	
	public Settings(Settings settings) {
		super(settings);
	}
	
	public Settings(OptionsContainer options) {
		super();
		synchronized(optionMap) {
			for(OptionWidget option : options.getOptionList()) {
				String value = options.getValueOf(option.getDescription());
				String key = option.getDescription().toString();
				SettingsOption sOption = new SettingsOption(key, value);
				optionMap.put(key, sOption);
			}
		}
	}
	
	@Override
	public void copySettings(AbstractSettings<SettingsOption> settings, boolean reset) {
		for(String key : settings.getOptionMap().keySet()) {
			SettingsOption copy = settings.getOptionMap().get(key).getCopy();
			optionMap.put(new String(key), copy);
		}
	}
	
	public void addOption(String infoType, String info) {
		SettingsOption option = getOption(infoType);
		if(option == null) {
			option = new SettingsOption(infoType, info);
			optionMap.put(infoType, option);
		} else option.setValue(info); 
	}
	
	public void addOption(Lang infoType, String info) {
		addOption(infoType.toString(), info);
	}
}